<template>
    <div>
        <p>当前数字是：{{num}}</p>
        <p>孙子可使用资金：{{ childMoney }}</p>
        <button @click="add">+n</button>
        <button @click="kai">开航空母舰</button>
    </div>
</template>

<script setup>
     import {ref, defineEmits,inject} from 'vue';
    
     const emit = defineEmits(['updateSum']);

     const num = ref(0);
     const add = ()=>{
        num.value ++;
        emit('updateSum', num.value);
     }

     const childMoney = inject('familyMoney');
     const kai = ()=>{
        childMoney.value += 600000;
     }
</script>

<style lang="scess" scoped></style>